const currentGroupArray = _.chain(r1)
  .mapValues((value, key) => {
    const currentAccuracyList = value.accuracyList.slice(0, index + 1)
    // 计算准确率
    const stats = calcAccuracySummary(currentAccuracyList)
    return {
      groupName: key,
      groupType: value.group_type,
      accuracy_array: currentAccuracyList,
      stats
    }
  })
  .values()
  .value()

// 过滤
const filteredGroups = handleFilterGroups(currentGroupArray)
// 排序
const orderedGroups = handleOrderGroups(filteredGroups)

if (index === 99) {
  fs.writeFileSync(
    path.join(__dirname, 'json/​Steps-05-currentGroupArray.json'),
    JSON.stringify(currentGroupArray, null, 2),
    'utf8'
  )
  console.log('​Steps-05 currentGroupArray 长度：', currentGroupArray.length)

  fs.writeFileSync(
    path.join(__dirname, 'json/​Steps-06-filteredGroups.json'),
    JSON.stringify(filteredGroups, null, 2),
    'utf8'
  )
  console.log('​Steps-06 filteredGroups 长度：', filteredGroups.length)

  fs.writeFileSync(
    path.join(__dirname, 'json/​Steps-07-orderedGroups.json'),
    JSON.stringify(orderedGroups, null, 2),
    'utf8'
  )
  console.log('​Steps-07 orderedGroups 长度：', orderedGroups.length)
}

// 选号
const { lucky_array, kill_array, kill_group_names } = getLucky(orderedGroups, item, numberGroupMap, flatGroupMap)

if (lucky_array.length < 32) {
  return {
    ...item,
    lucky_array: [],
    kill_array: [],
    kill_group_names
  }
} else {
  return {
    ...item,
    lucky_array,
    kill_array,
    kill_group_names
  }
}




function slidingWindowTraversal(arr, windowSize) {
  const result = []

  // 滑动窗口遍历数组
  for (let i = 0; i <= arr.length - windowSize; i++) {
    console.log(i)
    // 截取长度为 windowSize 的子数组
    const window = arr.slice(i, i + windowSize)
    result.push(window)
    console.log(window) // 可以查看每个窗口的内容
  }

  return result // 返回所有窗口的数组
}